package o2o.web.actions.sys;

import com.jinyou.utils.common.JYFileUtils;
import o2o.config.dao.UserDaoSql;
import com.jinyou.utils.common.AjaxResult;
import com.jinyou.utils.common.ObjectUtils;
import com.jinyou.utils.common.ValidateUtil;
import o2o.cache.sys.SysConfigPayMemory;
import o2o.cache.user.UserInfoMemory;
import o2o.cache.user.UserOnlineImpl;
import o2o.dao.PO.PojoTables;
import o2o.dao.PO.common.ResultInfo;
import o2o.dao.PO.sys.SysConfigPay;
import o2o.dao.PO.user.UserInfo;
import o2o.dao.VO.common.FileUploadInfo;
import o2o.dao.VO.sys.SysConfigPayVO2;
import o2o.system.data.SYS_CONFIG_PATH;
import o2o.web.actions.user.User;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import pay.config.PayConfig;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

//系统设置

@Controller
public class SysConfigPayAction {

    //更新支付配置信息
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/config/pay/reload")
    @ResponseBody
    public String sys_list() {
        SysConfigPayMemory.getInstance().run();

        //初始化支付相关
        ResultInfo resultInfo = PayConfig.init();
        if (null == resultInfo) {
            return AjaxResult.errorResult("初始化失败");
        }
        if (!resultInfo.isSuccess()) {
            return AjaxResult.errorResult("初始化失败");
        }

        return AjaxResult.successResult();
    }

    //获取支付配置列表
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/config/pay/list")
    @ResponseBody
    public String sysConfigPayList(String token) {
        //登录验证
        UserInfo user = UserInfoMemory.getInstance().getUserInfo(UserOnlineImpl.getInstance().get(token));
        if (user == null) {
//            return AjaxResult.errorLogoutResult();
        }
//        //权限验证
//        if (!User.getInstance().hasSuperAdminAuth(user.getUserType())) {
//            return AjaxResult.errorResult("您没有访问权限");
//        }
        List<SysConfigPay> list = SysConfigPayMemory.getInstance().getAllListSysConfigPay();
        List<SysConfigPayVO2> sysConfigPayVO2s = new ArrayList<>();
        SysConfigPayVO2 s2 = null;
        if (ValidateUtil.isAbsList(list)) {
            for (int index = 0; index < list.size(); index++) {
                if (null == list.get(index)) {
                    continue;
                }
                s2 = new SysConfigPayVO2();
                try {
                    ObjectUtils.copyPropertiesExclude(list.get(index), s2, null);
                } catch (Exception e) {
                    e.printStackTrace();
                    continue;
                }
                sysConfigPayVO2s.add(s2);
            }
        }
        return AjaxResult.successResult(sysConfigPayVO2s.size(), sysConfigPayVO2s);
    }

    //支付配置修改
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/config/pay/update")
    @ResponseBody
    public String updateSysConfigPay(String token, SysConfigPayVO2 sysConfigPayVO2, FileUploadInfo fileUploadInfo) {
        //登录验证
        UserInfo user = UserInfoMemory.getInstance().getUserInfo(UserOnlineImpl.getInstance().get(token));
        if (user == null) {
//            return AjaxResult.errorLogoutResult();
        }
        //权限验证
//        if (!User.getInstance().hasSuperAdminAuth(user.getUserType())) {
//            return AjaxResult.errorResult("您没有访问权限");
//        }
        if (!ValidateUtil.isID(sysConfigPayVO2.getId())) {
            return AjaxResult.errorResult("id不能为空");
        }
        SysConfigPay sysConfigPay = SysConfigPayMemory.getInstance().getById(sysConfigPayVO2.getId());

        //理论上不存在此情况
        if (null == sysConfigPay) {
            return AjaxResult.errorResult("修改错误，请稍后重试");
        }
        boolean isUpdatePay = false;
        StringBuffer sb = new StringBuffer();
        sb.append("update ").append(PojoTables.SYS_CONFIG_PAY).append(" set ");

        if (null != sysConfigPayVO2.getAppFlag() && !sysConfigPayVO2.getAppFlag().equals(sysConfigPay.getAppFlag())) {
            isUpdatePay = true;
            sb.append(" appFlag = '").append(sysConfigPayVO2.getAppFlag()).append("',");
        }

        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPaySubject()) && !sysConfigPayVO2.getPaySubject().equals(sysConfigPay.getPaySubject())) {
            isUpdatePay = true;
            sb.append(" paySubject = '").append(sysConfigPayVO2.getPaySubject()).append("',");
        }

        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPayContent()) && !sysConfigPayVO2.getPayContent().equals(sysConfigPay.getPayContent())) {
            isUpdatePay = true;
            sb.append(" payContent = '").append(sysConfigPayVO2.getPayContent()).append("',");
        }
        //aliPartner
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPartner()) && !sysConfigPayVO2.getAliPartner().equals(sysConfigPay.getAliPartner())) {
            isUpdatePay = true;
            sb.append(" aliPartner='").append(sysConfigPayVO2.getAliPartner()).append("',");
        }
        //aliSellerId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliSellerId()) && !sysConfigPayVO2.getAliSellerId().equals(sysConfigPay.getAliSellerId())) {
            isUpdatePay = true;
            sb.append(" aliSellerId = '").append(sysConfigPayVO2.getAliSellerId()).append("',");
        }
        //aliPrivateKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPrivateKey()) && !sysConfigPayVO2.getAliPrivateKey().equals(sysConfigPay.getAliPrivateKey())) {
            isUpdatePay = true;
            sb.append(" aliPrivateKey = '").append(sysConfigPayVO2.getAliPrivateKey()).append("',");
        }
        //aliPublicKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPublicKey()) && !sysConfigPayVO2.getAliPublicKey().equals(sysConfigPay.getAliPublicKey())) {
            isUpdatePay = true;
            sb.append(" aliPublicKey = '").append(sysConfigPayVO2.getAliPublicKey()).append("',");
        }
        //aliAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliAppId()) && !sysConfigPayVO2.getAliAppId().equals(sysConfigPay.getAliAppId())) {
            isUpdatePay = true;
            sb.append(" aliAppId = '").append(sysConfigPayVO2.getAliAppId()).append("',");
        }
        //aliGateway
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliGateway()) && !sysConfigPayVO2.getAliGateway().equals(sysConfigPay.getAliGateway())) {
            isUpdatePay = true;
            sb.append(" aliGateway = '").append(sysConfigPayVO2.getAliGateway()).append("',");
        }
        //aliNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliNotifyUrl()) && !sysConfigPayVO2.getAliNotifyUrl().equals(sysConfigPay.getAliNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" aliNotifyUrl = '").append(sysConfigPayVO2.getAliNotifyUrl()).append("',");
        }
        //aliSignType
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliSignType()) && !sysConfigPayVO2.getAliSignType().equals(sysConfigPay.getAliSignType())) {
            isUpdatePay = true;
            sb.append(" aliSignType = '").append(sysConfigPayVO2.getAliSignType()).append("',");
        }
        //wxAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxAppId()) && !sysConfigPayVO2.getWxAppId().equals(sysConfigPay.getWxAppId())) {
            isUpdatePay = true;
            sb.append(" wxAppId = '").append(sysConfigPayVO2.getWxAppId()).append("',");
        }
        //wxApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxApiKey()) && !sysConfigPayVO2.getWxApiKey().equals(sysConfigPay.getWxApiKey())) {
            isUpdatePay = true;
            sb.append(" wxApiKey = '").append(sysConfigPayVO2.getWxApiKey()).append("',");
        }
        //wxAppSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxAppSecret()) && !sysConfigPayVO2.getWxAppSecret().equals(sysConfigPay.getWxAppSecret())) {
            isUpdatePay = true;
            sb.append(" wxAppSecret = '").append(sysConfigPayVO2.getWxAppSecret()).append("',");
        }
        //wxMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxMchId()) && !sysConfigPayVO2.getWxMchId().equals(sysConfigPay.getWxMchId())) {
            isUpdatePay = true;
            sb.append(" wxMchId = '").append(sysConfigPayVO2.getWxMchId()).append("',");
        }
        //wxNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxNotifyUrl()) && !sysConfigPayVO2.getWxNotifyUrl().equals(sysConfigPay.getWxNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" wxNotifyUrl = '").append(sysConfigPayVO2.getWxNotifyUrl()).append("',");
        }
        //wxCertFilePath
        // if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxCertFilePath()) && !sysConfigPayVO2.getWxCertFilePath().equals(sysConfigPay.getWxCertFilePath())) {
        //     isUpdatePay = true;
        //     sb.append(" wxCertFilePath = '").append(sysConfigPayVO2.getWxCertFilePath()).append("',");
        // }
        String path = SYS_CONFIG_PATH.WX_CERT_URL + "/" + sysConfigPay.getAgentId() + "/";

        String wxCertFilePath = "";
        String wxGzhCertFilePath = "";
        String wxXcxCertFilePath = "";
        if (null != fileUploadInfo) {
            //微信退款证书上传
            if (null != fileUploadInfo.getFile()) {
                try {
                    isUpdatePay = true;
                    wxCertFilePath = JYFileUtils.multipartFile(fileUploadInfo.getFile(), path);
                } catch (Exception e) {
                    return AjaxResult.errorResult("微信退款证书上传失败");
                }
            } else {
                if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxCertFilePath()) && !sysConfigPayVO2.getWxCertFilePath().equals(sysConfigPay.getWxCertFilePath())) {
                    wxCertFilePath = sysConfigPayVO2.getWxCertFilePath();
                }
            }
            if (ValidateUtil.isNotNull(wxCertFilePath) && !wxCertFilePath.equals(sysConfigPay.getWxCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxCertFilePath = '").append(wxCertFilePath).append("',");
            }
            //微信公众号退款证书上传
            if (null != fileUploadInfo.getFile1()) {
                try {
                    isUpdatePay = true;
                    wxGzhCertFilePath = JYFileUtils.multipartFile(fileUploadInfo.getFile1(), path);
                } catch (Exception e) {
                    return AjaxResult.errorResult("微信公众号退款证书上传失败");
                }
            } else {
                if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhCertFilePath()) && !sysConfigPayVO2.getWxGzhCertFilePath().equals(sysConfigPay.getWxGzhCertFilePath())) {
                    wxGzhCertFilePath = sysConfigPayVO2.getWxGzhCertFilePath();
                }
            }
            if (ValidateUtil.isNotNull(wxGzhCertFilePath) && !wxGzhCertFilePath.equals(sysConfigPay.getWxGzhCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxGzhCertFilePath = '").append(wxGzhCertFilePath).append("',");
            }
            //微信小程序退款证书上传
            if (null != fileUploadInfo.getFile2()) {
                try {
                    wxXcxCertFilePath = JYFileUtils.multipartFile(fileUploadInfo.getFile2(), path);
                } catch (Exception e) {
                    return AjaxResult.errorResult("微信小程序退款证书上传失败");
                }
            } else {
                if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxCertFilePath()) && !sysConfigPayVO2.getWxXcxCertFilePath().equals(sysConfigPay.getWxXcxCertFilePath())) {
                    wxXcxCertFilePath = sysConfigPayVO2.getWxXcxCertFilePath();
                }
            }
            if (ValidateUtil.isNotNull(wxXcxCertFilePath) && !wxXcxCertFilePath.equals(sysConfigPay.getWxXcxCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxXcxCertFilePath = '").append(wxXcxCertFilePath).append("',");
            }
        } else {
            //未上传证书文件
            if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxCertFilePath()) && !sysConfigPayVO2.getWxCertFilePath().equals(sysConfigPay.getWxCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxCertFilePath = '").append(sysConfigPayVO2.getWxCertFilePath()).append("',");
            }
            if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhCertFilePath()) && !sysConfigPayVO2.getWxGzhCertFilePath().equals(sysConfigPay.getWxGzhCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxGzhCertFilePath = '").append(sysConfigPayVO2.getWxGzhCertFilePath()).append("',");
            }
            if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxCertFilePath()) && !sysConfigPayVO2.getWxXcxCertFilePath().equals(sysConfigPay.getWxXcxCertFilePath())) {
                isUpdatePay = true;
                sb.append(" wxXcxCertFilePath = '").append(sysConfigPayVO2.getWxXcxCertFilePath()).append("',");
            }
        }
        if (ValidateUtil.isNotNull(wxCertFilePath) && !wxCertFilePath.equals(sysConfigPay.getWxCertFilePath())) {
            sb.append(" wxCertFilePath = '").append(wxCertFilePath).append("',");
        }
        //wxGzhMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhMchId()) && !sysConfigPayVO2.getWxGzhMchId().equals(sysConfigPay.getWxGzhMchId())) {
            isUpdatePay = true;
            sb.append(" wxGzhMchId = '").append(sysConfigPayVO2.getWxGzhMchId()).append("',");
        }
        //wxGzhAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhAppId()) && !sysConfigPayVO2.getWxGzhAppId().equals(sysConfigPay.getWxGzhAppId())) {
            isUpdatePay = true;
            sb.append(" wxGzhAppId = '").append(sysConfigPayVO2.getWxGzhAppId()).append("',");
        }
        //wxGzhApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhApiKey()) && !sysConfigPayVO2.getWxGzhApiKey().equals(sysConfigPay.getWxGzhApiKey())) {
            isUpdatePay = true;
            sb.append(" wxGzhApiKey = '").append(sysConfigPayVO2.getWxGzhApiKey()).append("',");
        }
        //wxGzhAppSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhAppSecret()) && !sysConfigPayVO2.getWxGzhAppSecret().equals(sysConfigPay.getWxGzhAppSecret())) {
            isUpdatePay = true;
            sb.append(" wxGzhAppSecret = '").append(sysConfigPayVO2.getWxGzhAppSecret()).append("',");
        }
        //wxGzhApiNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhApiNotifyUrl()) && !sysConfigPayVO2.getWxGzhApiNotifyUrl().equals(sysConfigPay.getWxGzhApiNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" wxGzhApiNotifyUrl = '").append(sysConfigPayVO2.getWxGzhApiNotifyUrl()).append("',");
        }
        //wxGzhCertFilePath
        // if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhCertFilePath()) && !sysConfigPayVO2.getWxGzhCertFilePath().equals(sysConfigPay.getWxGzhCertFilePath())) {
        //     isUpdatePay = true;
        //     sb.append(" wxGzhCertFilePath = '").append(sysConfigPayVO2.getWxGzhCertFilePath()).append("',");
        // }

        //wxXcxAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxAppId()) && !sysConfigPayVO2.getWxXcxAppId().equals(sysConfigPay.getWxXcxAppId())) {
            isUpdatePay = true;
            sb.append(" wxXcxAppId = '").append(sysConfigPayVO2.getWxXcxAppId()).append("',");
        }
        //wxXcxAppSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxAppSecret()) && !sysConfigPayVO2.getWxXcxAppSecret().equals(sysConfigPay.getWxXcxAppSecret())) {
            isUpdatePay = true;
            sb.append(" wxXcxAppSecret = '").append(sysConfigPayVO2.getWxXcxAppSecret()).append("',");
        }
        //wxXcxMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxMchId()) && !sysConfigPayVO2.getWxXcxMchId().equals(sysConfigPay.getWxXcxMchId())) {
            isUpdatePay = true;
            sb.append(" wxXcxMchId = '").append(sysConfigPayVO2.getWxXcxMchId()).append("',");
        }
        //wxXcxApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxApiKey()) && !sysConfigPayVO2.getWxXcxApiKey().equals(sysConfigPay.getWxXcxApiKey())) {
            isUpdatePay = true;
            sb.append(" wxXcxApiKey = '").append(sysConfigPayVO2.getWxXcxApiKey()).append("',");
        }
        //wxXcxApiNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxApiNotifyUrl()) && !sysConfigPayVO2.getWxXcxApiNotifyUrl().equals(sysConfigPay.getWxXcxApiNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" wxXcxApiNotifyUrl = '").append(sysConfigPayVO2.getWxXcxApiNotifyUrl()).append("',");
        }
        //wxXcxCertFilePath
        // if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxCertFilePath()) && !sysConfigPayVO2.getWxXcxCertFilePath().equals(sysConfigPay.getWxXcxCertFilePath())) {
        //     isUpdatePay = true;
        //     sb.append(" wxXcxCertFilePath = '").append(sysConfigPayVO2.getWxXcxCertFilePath()).append("',");
        // }

        // nihaopay是正式版吗  0测试版 1正式版
        if (null != sysConfigPayVO2.getNhpLive()) {
            isUpdatePay = true;
            sb.append(" nhpLive = ").append(sysConfigPayVO2.getNhpLive()).append(",");
        }

        // nihaopayToken
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpToken()) && !sysConfigPayVO2.getNhpToken().equals(sysConfigPay.getNhpToken())) {
            isUpdatePay = true;
            sb.append(" nhpToken = '").append(sysConfigPayVO2.getNhpToken()).append("',");
        }

        // nihaopay货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpCurrency()) && !sysConfigPayVO2.getNhpCurrency().equals(sysConfigPay.getNhpCurrency())) {
            isUpdatePay = true;
            sb.append(" nhpCurrency = '").append(sysConfigPayVO2.getNhpCurrency()).append("',");
        }

        // nihaopay回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpNotifyUrl()) && !sysConfigPayVO2.getNhpNotifyUrl().equals(sysConfigPay.getNhpNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" nhpNotifyUrl = '").append(sysConfigPayVO2.getNhpNotifyUrl()).append("',");
        }

        // nihaopay是否需要系统换算汇率（日元时不需系统换算）1 需要换算 0不需要换算
        if (null != sysConfigPayVO2.getNhpUseRate() && !sysConfigPayVO2.getNhpUseRate().equals(sysConfigPay.getNhpUseRate())) {
            isUpdatePay = true;
            sb.append(" nhpUseRate = '").append(sysConfigPayVO2.getNhpUseRate()).append("',");
        }

        // paypay/linepay是正式版吗  0测试版 1正式版
        if (null != sysConfigPayVO2.getLpLive()) {
            isUpdatePay = true;
            sb.append(" lpLive = ").append(sysConfigPayVO2.getLpLive()).append(",");
        }

        // paypay/linepay商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpMid()) && !sysConfigPayVO2.getLpMid().equals(sysConfigPay.getLpMid())) {
            isUpdatePay = true;
            sb.append(" lpMid = '").append(sysConfigPayVO2.getLpMid()).append("',");
        }

        // paypay/linepay签名密钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpKey()) && !sysConfigPayVO2.getLpKey().equals(sysConfigPay.getLpKey())) {
            isUpdatePay = true;
            sb.append(" lpKey = '").append(sysConfigPayVO2.getLpKey()).append("',");
        }

        // paypay/linepay加密密钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpEncryKey()) && !sysConfigPayVO2.getLpEncryKey().equals(sysConfigPay.getLpEncryKey())) {
            isUpdatePay = true;
            sb.append(" lpEncryKey = '").append(sysConfigPayVO2.getLpEncryKey()).append("',");
        }

        // paypay/linepay商户币种(392 日元)
        if (!ValidateUtil.isNull(sysConfigPayVO2.getLpCurrency())) {
            isUpdatePay = true;
            sb.append(" lpCurrency = ").append(sysConfigPayVO2.getLpCurrency()).append(",");
        }

        // paypay/linepay回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpNotifyUrl()) && !sysConfigPayVO2.getLpNotifyUrl().equals(sysConfigPay.getLpNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" lpNotifyUrl = '").append(sysConfigPayVO2.getLpNotifyUrl()).append("',");
        }

        // EasyEuro商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeMchId()) && !sysConfigPayVO2.getEeMchId().equals(sysConfigPay.getEeMchId())) {
            isUpdatePay = true;
            sb.append(" eeMchId = '").append(sysConfigPayVO2.getEeMchId()).append("',");
        }

        // EasyEuroApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeApiKey()) && !sysConfigPayVO2.getEeApiKey().equals(sysConfigPay.getEeApiKey())) {
            isUpdatePay = true;
            sb.append(" eeApiKey = '").append(sysConfigPayVO2.getEeApiKey()).append("',");
        }

        // EasyEuro支付回调地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeNotifyUrl()) && !sysConfigPayVO2.getEeNotifyUrl().equals(sysConfigPay.getEeNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" eeNotifyUrl = '").append(sysConfigPayVO2.getEeNotifyUrl()).append("',");
        }

        //Ksher商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsMchId()) && !sysConfigPayVO2.getKsMchId().equals(sysConfigPay.getKsMchId())) {
            isUpdatePay = true;
            sb.append(" ksMchId = '").append(sysConfigPayVO2.getKsMchId()).append("',");
        }

        //Ksher货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsCurrency()) && !sysConfigPayVO2.getKsCurrency().equals(sysConfigPay.getKsCurrency())) {
            isUpdatePay = true;
            sb.append(" ksCurrency = '").append(sysConfigPayVO2.getKsCurrency()).append("',");
        }

        //Ksher公钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsPublicKey()) && !sysConfigPayVO2.getKsPublicKey().equals(sysConfigPay.getKsPublicKey())) {
            isUpdatePay = true;
            sb.append(" ksPublicKey = '").append(sysConfigPayVO2.getKsPublicKey()).append("',");
        }

        //Ksher私钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsPrivateKey()) && !sysConfigPayVO2.getKsPrivateKey().equals(sysConfigPay.getKsPrivateKey())) {
            isUpdatePay = true;
            sb.append(" ksPrivateKey = '").append(sysConfigPayVO2.getKsPrivateKey()).append("',");
        }

        //Ksher回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsNotifyUrl()) && !sysConfigPayVO2.getKsNotifyUrl().equals(sysConfigPay.getKsNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ksNotifyUrl = '").append(sysConfigPayVO2.getKsNotifyUrl()).append("',");
        }

        //Ksher是否需要汇率转换
        if (null != sysConfigPayVO2.getKsUseRate()) {
            isUpdatePay = true;
            sb.append(" ksUseRate = ").append(sysConfigPayVO2.getKsUseRate()).append(",");
        }

        //Citcon支付是正式版吗
        if (null != sysConfigPayVO2.getCcLive()) {
            isUpdatePay = true;
            sb.append(" ccLive = ").append(sysConfigPayVO2.getCcLive()).append(",");
        }

        // Citcon Token
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcToken()) && !sysConfigPayVO2.getCcToken().equals(sysConfigPay.getCcToken())) {
            isUpdatePay = true;
            sb.append(" ccToken = '").append(sysConfigPayVO2.getCcToken()).append("',");
        }
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcXcxToken()) && !sysConfigPayVO2.getCcXcxToken().equals(sysConfigPay.getCcXcxToken())) {
            isUpdatePay = true;
            sb.append(" ccXcxToken = '").append(sysConfigPayVO2.getCcXcxToken()).append("',");
        }


        // Citcon币种
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcCurrency()) && !sysConfigPayVO2.getCcCurrency().equals(sysConfigPay.getCcCurrency())) {
            isUpdatePay = true;
            sb.append(" ccCurrency = '").append(sysConfigPayVO2.getCcCurrency()).append("',");
        }

        // Citcon回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcNotifyUrl()) && !sysConfigPayVO2.getCcNotifyUrl().equals(sysConfigPay.getCcNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ccNotifyUrl = '").append(sysConfigPayVO2.getCcNotifyUrl()).append("',");
        }
        // Citcon回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcXcxNotifyUrl()) && !sysConfigPayVO2.getCcXcxNotifyUrl().equals(sysConfigPay.getCcXcxNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ccXcxNotifyUrl = '").append(sysConfigPayVO2.getCcXcxNotifyUrl()).append("',");
        }

        //Citcon是否需要汇率转换
        if (null != sysConfigPayVO2.getCcUseRate()) {
            isUpdatePay = true;
            sb.append(" ccUseRate = ").append(sysConfigPayVO2.getCcUseRate()).append(",");
        }

        // 微信商家 appid
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxShopAppId()) && !sysConfigPayVO2.getWxShopAppId().equals(sysConfigPay.getWxShopAppId())) {
            isUpdatePay = true;
            sb.append(" wxShopAppId = '").append(sysConfigPayVO2.getWxShopAppId()).append("',");
        }

        // 微信商家 apiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxShopApiKey()) && !sysConfigPayVO2.getWxShopApiKey().equals(sysConfigPay.getWxShopApiKey())) {
            isUpdatePay = true;
            sb.append(" wxShopApiKey = '").append(sysConfigPayVO2.getWxShopApiKey()).append("',");
        }

        // 微信商家 app secret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxShopAppSecret()) && !sysConfigPayVO2.getWxShopAppSecret().equals(sysConfigPay.getWxShopAppSecret())) {
            isUpdatePay = true;
            sb.append(" wxShopAppSecret = '").append(sysConfigPayVO2.getWxShopAppSecret()).append("',");
        }

        // 微信商家 mch_id
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxShopMchId()) && !sysConfigPayVO2.getWxShopMchId().equals(sysConfigPay.getWxShopMchId())) {
            isUpdatePay = true;
            sb.append(" wxShopMchId = '").append(sysConfigPayVO2.getWxShopMchId()).append("',");
        }
        // 骑手微信appid
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxQsAppId()) && !sysConfigPayVO2.getWxQsAppId().equals(sysConfigPay.getWxQsAppId())) {
            isUpdatePay = true;
            sb.append(" wxQsAppId = '").append(sysConfigPayVO2.getWxQsAppId()).append("',");
        }

        // 骑手微信key
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxQsApiKey()) && !sysConfigPayVO2.getWxQsApiKey().equals(sysConfigPay.getWxQsApiKey())) {
            isUpdatePay = true;
            sb.append(" wxQsApiKey = '").append(sysConfigPayVO2.getWxQsApiKey()).append("',");
        }
        // 骑手微信secret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxQsAppSecret()) && !sysConfigPayVO2.getWxQsAppSecret().equals(sysConfigPay.getWxQsAppSecret())) {
            isUpdatePay = true;
            sb.append(" wxQsAppSecret = '").append(sysConfigPayVO2.getWxQsAppSecret()).append("',");
        }
        // 骑手微信 mch_id
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxQsMchId()) && !sysConfigPayVO2.getWxQsMchId().equals(sysConfigPay.getWxQsMchId())) {
            isUpdatePay = true;
            sb.append(" wxQsMchId = '").append(sysConfigPayVO2.getWxQsMchId()).append("',");
        }

        //  Stripe的公钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getStPublic()) && !sysConfigPayVO2.getStPublic().equals(sysConfigPay.getStPublic())) {
            isUpdatePay = true;
            sb.append(" stPublic = '").append(sysConfigPayVO2.getStPublic()).append("',");
        }
        // stripe 的私钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getStSecret()) && !sysConfigPayVO2.getStSecret().equals(sysConfigPay.getStSecret())) {
            isUpdatePay = true;
            sb.append(" stSecret = '").append(sysConfigPayVO2.getStSecret()).append("',");
        }
        // stripe的货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getStCurrency()) && !sysConfigPayVO2.getStCurrency().equals(sysConfigPay.getStCurrency())) {
            isUpdatePay = true;
            sb.append(" stCurrency = '").append(sysConfigPayVO2.getStCurrency()).append("',");
        }
        // 收集信用卡的地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getStLocalUrl()) && !sysConfigPayVO2.getStLocalUrl().equals(sysConfigPay.getStLocalUrl())) {
            isUpdatePay = true;
            sb.append(" stLocalUrl = '").append(sysConfigPayVO2.getStLocalUrl()).append("',");
        }
        // 成功后跳转地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getStSuccessUrl()) && !sysConfigPayVO2.getStSuccessUrl().equals(sysConfigPay.getStSuccessUrl())) {
            isUpdatePay = true;
            sb.append(" stSuccessUrl = '").append(sysConfigPayVO2.getStSuccessUrl()).append("',");
        }
        //  apacpay商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacMerNo()) && !sysConfigPayVO2.getApacMerNo().equals(sysConfigPay.getApacMerNo())) {
            isUpdatePay = true;
            sb.append(" apacMerNo = '").append(sysConfigPayVO2.getApacMerNo()).append("',");
        }
        //  apacpay 子账户
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacGatewayNo()) && !sysConfigPayVO2.getApacGatewayNo().equals(sysConfigPay.getApacGatewayNo())) {
            isUpdatePay = true;
            sb.append(" apacGatewayNo = '").append(sysConfigPayVO2.getApacGatewayNo()).append("',");
        }
        //  apacpay 货币类型
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacCurrency()) && !sysConfigPayVO2.getApacCurrency().equals(sysConfigPay.getApacCurrency())) {
            isUpdatePay = true;
            sb.append(" apacCurrency = '").append(sysConfigPayVO2.getApacCurrency()).append("',");
        }
        //  apacpay 货币类型
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacCurrency()) && !sysConfigPayVO2.getApacCurrency().equals(sysConfigPay.getApacCurrency())) {
            isUpdatePay = true;
            sb.append(" apacCurrency = '").append(sysConfigPayVO2.getApacCurrency()).append("',");
        }
        //  apacpay签名
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacSignKey()) && !sysConfigPayVO2.getApacSignKey().equals(sysConfigPay.getApacSignKey())) {
            isUpdatePay = true;
            sb.append(" apacSignKey = '").append(sysConfigPayVO2.getApacSignKey()).append("',");
        }
        //  apacpay请求签名接口地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacSignUrl()) && !sysConfigPayVO2.getApacSignUrl().equals(sysConfigPay.getApacSignUrl())) {
            isUpdatePay = true;
            sb.append(" apacSignUrl = '").append(sysConfigPayVO2.getApacSignUrl()).append("',");
        }
        //  apacpay请求支付接口地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacPayUrl()) && !sysConfigPayVO2.getApacPayUrl().equals(sysConfigPay.getApacPayUrl())) {
            isUpdatePay = true;
            sb.append(" apacPayUrl = '").append(sysConfigPayVO2.getApacPayUrl()).append("',");
        }
        //  apacpay请求支付接口地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacLocalUrl()) && !sysConfigPayVO2.getApacLocalUrl().equals(sysConfigPay.getApacLocalUrl())) {
            isUpdatePay = true;
            sb.append(" apacLocalUrl = '").append(sysConfigPayVO2.getApacLocalUrl()).append("',");
        }
        //  apacpay支付页面返回地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacLocalReturnUrl()) && !sysConfigPayVO2.getApacLocalReturnUrl().equals(sysConfigPay.getApacLocalReturnUrl())) {
            isUpdatePay = true;
            sb.append(" apacLocalReturnUrl = '").append(sysConfigPayVO2.getApacLocalReturnUrl()).append("',");
        }
        //  apacpay支付页面取消返回地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacLocalCancelUrl()) && !sysConfigPayVO2.getApacLocalCancelUrl().equals(sysConfigPay.getApacLocalCancelUrl())) {
            isUpdatePay = true;
            sb.append(" apacLocalCancelUrl = '").append(sysConfigPayVO2.getApacLocalCancelUrl()).append("',");
        }
        //  apacpay支付回调地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacNotifyUrl()) && !sysConfigPayVO2.getApacNotifyUrl().equals(sysConfigPay.getApacNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" apacNotifyUrl = '").append(sysConfigPayVO2.getApacNotifyUrl()).append("',");
        }
        //  apacpay请求查询接口地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacCheckUrl()) && !sysConfigPayVO2.getApacCheckUrl().equals(sysConfigPay.getApacCheckUrl())) {
            isUpdatePay = true;
            sb.append(" apacCheckUrl = '").append(sysConfigPayVO2.getApacCheckUrl()).append("',");
        }
        //  apacpay请求退款接口地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getApacRefundUrl()) && !sysConfigPayVO2.getApacRefundUrl().equals(sysConfigPay.getApacRefundUrl())) {
            isUpdatePay = true;
            sb.append(" apacRefundUrl = '").append(sysConfigPayVO2.getApacRefundUrl()).append("',");
        }


        //  paypal支付ClientId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpClientId()) && !sysConfigPayVO2.getPpClientId().equals(sysConfigPay.getPpClientId())) {
            isUpdatePay = true;
            sb.append(" ppClientId = '").append(sysConfigPayVO2.getPpClientId()).append("',");
        }
        //  paypal支付ClientSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpClientSecret()) && !sysConfigPayVO2.getPpClientSecret().equals(sysConfigPay.getPpClientSecret())) {
            isUpdatePay = true;
            sb.append(" ppClientSecret = '").append(sysConfigPayVO2.getPpClientSecret()).append("',");
        }
        //  paypal支付货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpCurrency()) && !sysConfigPayVO2.getPpCurrency().equals(sysConfigPay.getPpCurrency())) {
            isUpdatePay = true;
            sb.append(" ppCurrency = '").append(sysConfigPayVO2.getPpCurrency()).append("',");
        }
        //  paypal支付mode
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpMode()) && !sysConfigPayVO2.getPpMode().equals(sysConfigPay.getPpMode())) {
            isUpdatePay = true;
            sb.append(" ppMode = '").append(sysConfigPayVO2.getPpMode()).append("',");
        }
        //  paypal支付失败或成功后调用本地地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpLocalNotifyUrl()) && !sysConfigPayVO2.getPpLocalNotifyUrl().equals(sysConfigPay.getPpLocalNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ppLocalNotifyUrl = '").append(sysConfigPayVO2.getPpLocalNotifyUrl()).append("',");
        }
        //  paypal支付成功后调用地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpSuccessNotifyUrl()) && !sysConfigPayVO2.getPpSuccessNotifyUrl().equals(sysConfigPay.getPpSuccessNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ppSuccessNotifyUrl = '").append(sysConfigPayVO2.getPpSuccessNotifyUrl()).append("',");
        }
        //  paypal支付取消后调用地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPpCancelNotifyUrl()) && !sysConfigPayVO2.getPpCancelNotifyUrl().equals(sysConfigPay.getPpCancelNotifyUrl())) {
            isUpdatePay = true;
            sb.append(" ppCancelNotifyUrl = '").append(sysConfigPayVO2.getPpCancelNotifyUrl()).append("',");
        }
        // showNote
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getShowNote()) && !sysConfigPayVO2.getShowNote().equals(sysConfigPay.getShowNote())) {
            isUpdatePay = true;
            sb.append(" showNote = '").append(sysConfigPayVO2.getShowNote()).append("',");
        }
        // paypal支付是否可用（1可用，0不可用）
        if (null != sysConfigPayVO2.getIsPaypalAble()) {
            sb.append("isPaypalAble=").append(sysConfigPayVO2.getIsPaypalAble()).append(",");
        }
        // 是否可以货到付款（1可用，0不可用）
        if (null != sysConfigPayVO2.getIsCDeliveryAble()) {
            sb.append("isCDeliveryAble=").append(sysConfigPayVO2.getIsCDeliveryAble()).append(",");
        }
        // Stripe是否可用（1可用，0不可用）
        if (null != sysConfigPayVO2.getIsStripeAble()) {
            sb.append("isStripeAble=").append(sysConfigPayVO2.getIsStripeAble()).append(",");
        }
        // apacPay是否可用
        if (null != sysConfigPayVO2.getIsApacAble()) {
            sb.append("isApacAble=").append(sysConfigPayVO2.getIsApacAble()).append(",");
        }
        // 余额支付是否可用
        if (null != sysConfigPayVO2.getIsWalletAble()) {
            sb.append("isWalletAble=").append(sysConfigPayVO2.getIsWalletAble()).append(",");
        }
        if (null != sysConfigPayVO2.getIsAliAble()) {
            sb.append("isAliAble=").append(sysConfigPayVO2.getIsAliAble()).append(",");
        }
        if (null != sysConfigPayVO2.getIsWxAble()) {
            sb.append("isWxAble=").append(sysConfigPayVO2.getIsWxAble()).append(",");
        }
        if (null != sysConfigPayVO2.getIsPaypayAble()) {
            sb.append("isPaypayAble=").append(sysConfigPayVO2.getIsPaypayAble()).append(",");
        }
        if (null != sysConfigPayVO2.getIsLinepayAble()) {
            sb.append("isLinepayAble=").append(sysConfigPayVO2.getIsLinepayAble()).append(",");
        }
        if (null != user) {
            sb.append(" updateUser = '").append(user.getUsername()).append("'");
        } else {
            sb.append(" updateUser = ''");
        }
        sb.append(" where id =").append(sysConfigPayVO2.getId()).append(" ");
        if (!isUpdatePay) {
            return AjaxResult.errorResult("您没有更新任何信息");
        } else {
            try {
                UserDaoSql.getInstance().executeBySql(sb.toString());
            } catch (SQLException e) {
                e.printStackTrace();
                return AjaxResult.errorResult("更新失败，请稍后再试.");
            }
        }
        // SysConfigPayMemory.getInstance().run();
        sys_list();
        return AjaxResult.successResult();
    }

    //支付配置添加
    @RequestMapping(method = RequestMethod.POST, value = "/admin/sys/config/pay/add")
    @ResponseBody
    public String addSysConfigPay(String token, SysConfigPayVO2 sysConfigPayVO2, String key) {
        //登录验证
        UserInfo user = UserInfoMemory.getInstance().getUserInfo(UserOnlineImpl.getInstance().get(token));
        if (user == null) {
            return AjaxResult.errorLogoutResult();
        }
        //权限验证
        if (!User.getInstance().hasSuperAdminAuth(user.getUserType())) {
            return AjaxResult.errorResult("您没有访问权限");
        }
        boolean isInsertPay = false;
        String sql = "";
        sql += "insert into " + PojoTables.SYS_CONFIG_PAY + "(";
        StringBuffer temp = new StringBuffer();
        temp.append("value (");
        sql += "delFlag ,";
        temp.append(0).append(",");
        sql += "createUser,";
        temp.append("'").append(user.getUsername()).append("',");
        sql += "createTime ,";
        temp.append(new Date().getTime()).append(",");
        //key
        String sysAppKey = sysConfigPayVO2.getSysAppKey();
        if (ValidateUtil.isNull(sysAppKey) && ValidateUtil.isNotNull(key)) {
            sysAppKey = key;
        }
        if (ValidateUtil.isNotNull(sysAppKey)) {
            isInsertPay = true;
            sql += " `sysAppKey`,";
            temp.append("'").append(sysAppKey).append("',");
        }
        //agentId
        if (null != sysConfigPayVO2.getAgentId()) {
            isInsertPay = true;
            sql += " agentId,";
            temp.append(" ").append(sysConfigPayVO2.getAgentId()).append(",");
        }
        if (null != sysConfigPayVO2.getAppFlag()) {
            isInsertPay = true;
            sql += " appFlag,";
            temp.append(" '").append(sysConfigPayVO2.getAppFlag()).append("',");
        }
        //paySubject
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPaySubject())) {
            isInsertPay = true;
            sql += " paySubject,";
            temp.append("'").append(sysConfigPayVO2.getPaySubject()).append("',");
        }
        //payContent
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getPayContent())) {
            isInsertPay = true;
            sql += " payContent,";
            temp.append("'").append(sysConfigPayVO2.getPayContent()).append("',");
        }
        //aliPartner
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPartner())) {
            isInsertPay = true;
            sql += " aliPartner,";
            temp.append("'").append(sysConfigPayVO2.getAliPartner()).append("',");
        }
        //aliSellerId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliSellerId())) {
            isInsertPay = true;
            sql += " aliSellerId,";
            temp.append("'").append(sysConfigPayVO2.getAliSellerId()).append("',");
        }
        //aliPrivateKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPrivateKey())) {
            isInsertPay = true;
            sql += " aliPrivateKey,";
            temp.append("'").append(sysConfigPayVO2.getAliPrivateKey()).append("',");
        }
        //aliPublicKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliPublicKey())) {
            isInsertPay = true;
            sql += " aliPublicKey,";
            temp.append("'").append(sysConfigPayVO2.getAliPublicKey()).append("',");
        }
        //aliAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliAppId())) {
            isInsertPay = true;
            sql += " aliAppId,";
            temp.append("'").append(sysConfigPayVO2.getAliAppId()).append("',");
        }
        //aliGateway
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliGateway())) {
            isInsertPay = true;
            sql += " aliGateway,";
            temp.append("'").append(sysConfigPayVO2.getAliGateway()).append("',");
        }
        //aliNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliNotifyUrl())) {
            isInsertPay = true;
            sql += " aliNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getAliNotifyUrl()).append("',");
        }
        //aliSignType
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getAliSignType())) {
            isInsertPay = true;
            sql += " aliSignType,";
            temp.append("'").append(sysConfigPayVO2.getAliSignType()).append("',");
        }
        // wxAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxAppId())) {
            isInsertPay = true;
            sql += " wxAppId,";
            temp.append("'").append(sysConfigPayVO2.getWxAppId()).append("',");
        }
        //wxApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxApiKey())) {
            isInsertPay = true;
            sql += " wxApiKey,";
            temp.append("'").append(sysConfigPayVO2.getWxApiKey()).append("',");
        }
        //微信appSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxAppSecret())) {
            isInsertPay = true;
            sql += " wxAppSecret,";
            temp.append("'").append(sysConfigPayVO2.getWxAppSecret()).append("',");
        }
        //wxMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxMchId())) {
            isInsertPay = true;
            sql += " wxMchId,";
            temp.append("'").append(sysConfigPayVO2.getWxMchId()).append("',");
        }
        //wxNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxNotifyUrl())) {
            isInsertPay = true;
            sql += " wxNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getWxNotifyUrl()).append("',");
        }
        //wxCertFilePath
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxCertFilePath())) {
            isInsertPay = true;
            sql += " wxCertFilePath,";
            temp.append("'").append(sysConfigPayVO2.getWxCertFilePath()).append("',");
        }
        //wxGzhMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhMchId())) {
            isInsertPay = true;
            sql += " wxGzhMchId,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhMchId()).append("',");
        }
        //wxGzhAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhAppId())) {
            isInsertPay = true;
            sql += " wxGzhAppId,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhAppId()).append("',");
        }
        //wxGzhApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhApiKey())) {
            isInsertPay = true;
            sql += " wxGzhApiKey,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhApiKey()).append("',");
        }
        //wxGzhAppSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhAppSecret())) {
            isInsertPay = true;
            sql += " wxGzhAppSecret,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhAppSecret()).append("',");
        }
        //wxGzhApiNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhApiNotifyUrl())) {
            isInsertPay = true;
            sql += " wxGzhApiNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhApiNotifyUrl()).append("',");
        }
        //wxGzhCertFilePath
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxGzhCertFilePath())) {
            isInsertPay = true;
            sql += " wxGzhCertFilePath,";
            temp.append("'").append(sysConfigPayVO2.getWxGzhCertFilePath()).append("',");
        }
        //wxXcxAppId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxAppId())) {
            isInsertPay = true;
            sql += " wxXcxAppId,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxAppId()).append("',");
        }
        //wxXcxAppSecret
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxAppSecret())) {
            isInsertPay = true;
            sql += " wxXcxAppSecret,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxAppSecret()).append("',");
        }
        //wxXcxMchId
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxMchId())) {
            isInsertPay = true;
            sql += " wxXcxMchId,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxMchId()).append("',");
        }
        //wxXcxApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxApiKey())) {
            isInsertPay = true;
            sql += " wxXcxApiKey,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxApiKey()).append("',");
        }
        //wxXcxApiNotifyUrl
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxApiNotifyUrl())) {
            isInsertPay = true;
            sql += " wxXcxApiNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxApiNotifyUrl()).append("',");
        }
        //wxXcxCertFilePath
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getWxXcxCertFilePath())) {
            isInsertPay = true;
            sql += " wxXcxCertFilePath,";
            temp.append("'").append(sysConfigPayVO2.getWxXcxCertFilePath()).append("',");
        }
        //nhpLive nihaopay是正式版吗
        if (!ValidateUtil.isNull(sysConfigPayVO2.getNhpLive())) {
            isInsertPay = true;
            sql += " nhpLive,";
            temp.append(" ").append(sysConfigPayVO2.getNhpLive()).append(",");
        }
        //nhpToken nihaopayToken
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpToken())) {
            isInsertPay = true;
            sql += " nhpToken,";
            temp.append("'").append(sysConfigPayVO2.getNhpToken()).append("',");
        }
        //nhpCurrency nihaopay货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpCurrency())) {
            isInsertPay = true;
            sql += " nhpCurrency,";
            temp.append("'").append(sysConfigPayVO2.getNhpCurrency()).append("',");
        }
        //nhpNotifyUrl nihaopay回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getNhpNotifyUrl())) {
            isInsertPay = true;
            sql += " nhpNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getNhpNotifyUrl()).append("',");
        }
        //nhpUseRate nihaopay是否需要系统换算汇率
        if (ValidateUtil.isNull(sysConfigPayVO2.getNhpUseRate())) {
            isInsertPay = true;
            sql += " nhpUseRate,";
            temp.append(" ").append(sysConfigPayVO2.getNhpUseRate()).append(",");
        }
        //lpLive paypay/linepay是正式版吗
        if (ValidateUtil.isNull(sysConfigPayVO2.getLpLive())) {
            isInsertPay = true;
            sql += " lpLive,";
            temp.append(" ").append(sysConfigPayVO2.getLpLive()).append(",");
        }
        //lpMid paypay/linepay商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpMid())) {
            isInsertPay = true;
            sql += " lpMid,";
            temp.append("'").append(sysConfigPayVO2.getLpMid()).append("',");
        }
        //lpKey paypay/linepay签名密钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpKey())) {
            isInsertPay = true;
            sql += " lpKey,";
            temp.append("'").append(sysConfigPayVO2.getLpKey()).append("',");
        }
        //lpEncryKey paypay/linepay加密密钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpEncryKey())) {
            isInsertPay = true;
            sql += " lpEncryKey,";
            temp.append("'").append(sysConfigPayVO2.getLpEncryKey()).append("',");
        }
        //lpCurrency paypay/linepay商户币种(392 日元)
        if (ValidateUtil.isNull(sysConfigPayVO2.getLpCurrency())) {
            isInsertPay = true;
            sql += " lpCurrency,";
            temp.append(" ").append(sysConfigPayVO2.getLpCurrency()).append(",");
        }
        //lpNotifyUrl paypay/linepay回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getLpNotifyUrl())) {
            isInsertPay = true;
            sql += " lpNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getLpNotifyUrl()).append("',");
        }
        //eeMchId EasyEuro商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeMchId())) {
            isInsertPay = true;
            sql += " eeMchId,";
            temp.append("'").append(sysConfigPayVO2.getEeMchId()).append("',");
        }
        //eeApiKey EasyEuroApiKey
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeApiKey())) {
            isInsertPay = true;
            sql += " eeApiKey,";
            temp.append("'").append(sysConfigPayVO2.getEeApiKey()).append("',");
        }
        //eeNotifyUrl EasyEuro支付回调地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getEeNotifyUrl())) {
            isInsertPay = true;
            sql += " eeNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getEeNotifyUrl()).append("',");
        }
        //Ksher商户号
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsMchId())) {
            isInsertPay = true;
            sql += " ksMchId,";
            temp.append("'").append(sysConfigPayVO2.getKsMchId()).append("',");
        }
        //Ksher货币单位
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsCurrency())) {
            isInsertPay = true;
            sql += " ksCurrency,";
            temp.append("'").append(sysConfigPayVO2.getKsCurrency()).append("',");
        }
        //Ksher公钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsPublicKey())) {
            isInsertPay = true;
            sql += " ksPublicKey,";
            temp.append("'").append(sysConfigPayVO2.getKsPublicKey()).append("',");
        }
        //Ksher私钥
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsPrivateKey())) {
            isInsertPay = true;
            sql += " ksPrivateKey,";
            temp.append("'").append(sysConfigPayVO2.getKsPrivateKey()).append("',");
        }
        //Ksher回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getKsNotifyUrl())) {
            isInsertPay = true;
            sql += " ksNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getKsNotifyUrl()).append("',");
        }
        //Ksher是否需要汇率转换
        if (!ValidateUtil.isNull(sysConfigPayVO2.getKsUseRate())) {
            isInsertPay = true;
            sql += " ksUseRate,";
            temp.append(" ").append(sysConfigPayVO2.getKsUseRate()).append(",");
        }
        //Citcon支付是正式版吗
        if (!ValidateUtil.isNull(sysConfigPayVO2.getCcLive())) {
            isInsertPay = true;
            sql += " ccLive,";
            temp.append(" ").append(sysConfigPayVO2.getCcLive()).append(",");
        }
        //Citcon Token
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcToken())) {
            isInsertPay = true;
            sql += " ccToken,";
            temp.append("'").append(sysConfigPayVO2.getCcToken()).append("',");
        }
        //Citcon币种
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcCurrency())) {
            isInsertPay = true;
            sql += " ccCurrency,";
            temp.append("'").append(sysConfigPayVO2.getCcCurrency()).append("',");
        }
        //Citcon回调通知地址
        if (ValidateUtil.isNotNull(sysConfigPayVO2.getCcNotifyUrl())) {
            isInsertPay = true;
            sql += " ccNotifyUrl,";
            temp.append("'").append(sysConfigPayVO2.getCcNotifyUrl()).append("',");
        }
        //Citcon是否需要汇率转换
        if (!ValidateUtil.isNull(sysConfigPayVO2.getCcUseRate())) {
            isInsertPay = true;
            sql += " ccUseRate,";
            temp.append(" ").append(sysConfigPayVO2.getCcUseRate()).append(",");
        }
        //isAliAble
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsAliAble())) {
            isInsertPay = true;
            sql += " isAliAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsAliAble()).append(",");
        }
        //isWxAble
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsWxAble())) {
            isInsertPay = true;
            sql += " isWxAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsWxAble()).append(",");
        }
        //isPaypalAble paypal支付是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsPaypalAble())) {
            isInsertPay = true;
            sql += " isPaypalAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsPaypalAble()).append(",");
        }
        //isCDeliveryAble 货到付款支付是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsCDeliveryAble())) {
            isInsertPay = true;
            sql += " isCDeliveryAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsCDeliveryAble()).append(",");
        }
        //isStripeAble Stripe是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsStripeAble())) {
            isInsertPay = true;
            sql += " isStripeAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsStripeAble()).append(",");
        }
        //isApacAble apacPay是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsApacAble())) {
            isInsertPay = true;
            sql += " isApacAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsApacAble()).append(",");
        }
        //isWalletAble 余额支付是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsWalletAble())) {
            isInsertPay = true;
            sql += " isWalletAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsWalletAble()).append(",");
        }
        //isWoPayAble 联通沃支付是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsWoPayAble())) {
            isInsertPay = true;
            sql += " isWoPayAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsWoPayAble()).append(",");
        }
        //isTransitAble transit是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsTransitAble())) {
            isInsertPay = true;
            sql += " isTransitAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsTransitAble()).append(",");
        }
        //isPaypayAble paypay是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsPaypayAble())) {
            isInsertPay = true;
            sql += " isPaypayAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsPaypayAble()).append(",");
        }
        //isLinepayAble linepay是否可用
        if (!ValidateUtil.isNull(sysConfigPayVO2.getIsLinepayAble())) {
            isInsertPay = true;
            sql += " isLinepayAble,";
            temp.append(" ").append(sysConfigPayVO2.getIsLinepayAble()).append(",");
        }
        //showNote
        if (!ValidateUtil.isNull(sysConfigPayVO2.getShowNote())) {
            isInsertPay = true;
            sql += " showNote,";
            temp.append("'").append(sysConfigPayVO2.getShowNote()).append("',");
        }
        String SQL = new StringBuffer(sql).substring(0, sql.length() - 1);
        SQL += ") " + temp.substring(0, temp.length() - 1) + " )";
        if (!isInsertPay) {
            return AjaxResult.errorResult("你还没有提交任何信息~");
        }
        try {
            UserDaoSql.getInstance().executeBySql(SQL);
        } catch (SQLException e) {
            e.printStackTrace();
            return AjaxResult.errorResult("添加失败，请稍后再试.");
        }
        //更新缓存
        SysConfigPayMemory.getInstance().run();
        return AjaxResult.successResult();
    }


}
